package com.ruicar.afs.cloud.workflow.greatwall.feign;

import com.ruicar.afs.cloud.common.core.feign.annotations.AfsFeignClear;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "gwt-workflow", url = "${com.greatwall.systems.workflowEngine.uri}")
public interface GwtWorkFLowFeign {
    @GetMapping(value = "wft/start", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String startFlow(@RequestParam("serviceId") String serviceId, @RequestParam("dataId") String dataId, @RequestParam("name") String name);


    @PostMapping(value = "wft/run", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String taskSubmit(@RequestBody String string);


    @GetMapping(value = "wft/reformist", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String taskReformist(@RequestParam("finsid") String flowInstanceId, @RequestParam("userid") String userid, @RequestParam("username") String username);


    @GetMapping(value = "wft/commongiveup", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String flowGiveUp(@RequestParam("finsid") String flowInstanceId, @RequestParam("reason") String reason);


    @GetMapping(value = "wft/getcmd", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String queryCmd(@RequestParam("finisid") String flowInstanceId);


    @GetMapping(value = "wft/getfins", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String queryInstance(@RequestParam("finsId") String flowInstanceId);


    @GetMapping(value = "wft/backrun", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String taskCallBack(@RequestParam("finsId") String flowInstanceId, @RequestParam("userid") String userId, @RequestParam("username") String userName);


    @GetMapping(value = "wfc/getbypage/seatslist", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String pageSeatList(@RequestParam("pageSize") long pageSize, @RequestParam("pageIndex") long pageIndex);


    @GetMapping(value = "wfc/get/seatslist", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String seatList();


    @GetMapping(value = "wfc/get/taskuser", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String queryNodeUser(@RequestParam("pageSize") long pageSize, @RequestParam("pageIndex") long pageIndex, @RequestParam("taskId") String taskId);


    @PostMapping(value = "wfc/add/taskuser", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String addNodeUser(@RequestBody String requestBody);

    @GetMapping(value = "wfc/update/totalweight", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String changeUserTotalWeight(@RequestParam("userId") String userId, @RequestParam("totalWeight") int totalWeight);

    @GetMapping(value = "wfc/update/weight", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String changeUserWeight(@RequestParam("operId") String userIds, @RequestParam("weight") int weight);

    @GetMapping(value = "wfc/update/taskcount", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String clearTaskCount(@RequestParam("operIDs") String userIds);

    @GetMapping(value = "wfc/del/taskuser", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String removeNodeUsers(@RequestParam("operIds") String userIds);

    @GetMapping(value = "wfc/update/positions", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String moveUserToNode(@RequestParam("operId") String operId, @RequestParam("fromTaskId") String fromTaskId, @RequestParam("toTaskId") String toTaskId);

    @GetMapping(value = "wfc/update/retry", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String resumeFlowInstance(@RequestParam("dataId") String dataId, @RequestParam("eventId") String eventId);

    @GetMapping(value = "wfc/update/independently", consumes = MediaType.APPLICATION_JSON_VALUE)
    @AfsFeignClear(true)
    String pauseFlowInstance(@RequestParam("finId") String finId);

}
